﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PropBoom : MonoBehaviour {

    public ParticleSystem m_boomEffect;
    public Transform m_boomTransform;

	void Start () {
    }
	
	void Update () {
		
	}

    public void boomNow()
    {
        //Debug.Log("m_boomEffect.gameObject.activeInHierarchy=" + m_boomEffect.gameObject.activeInHierarchy);
        if(!m_boomEffect.gameObject.activeInHierarchy)
        {
            if(m_boomTransform==null) {
                m_boomEffect = Instantiate(m_boomEffect, transform.position, Quaternion.Euler(-90, 0, 0));
            }else
            {
                m_boomEffect = Instantiate(m_boomEffect, m_boomTransform.position, m_boomTransform.rotation);
            }
        }

        //目的是不跟随parent的destroy
        m_boomEffect.transform.parent = null;
        m_boomEffect.Stop();
        m_boomEffect.Play();
        Destroy(m_boomEffect.gameObject, m_boomEffect.main.duration);
    }
}
